package servlet;

import bean.User;
import dao.UserDao;
import dao.impl.UserDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class UpdateUserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id=req.getParameter("id");
        Integer userId=Integer.parseInt(id);
        System.out.println(userId);
        String username=req.getParameter("userName");
        String password=req.getParameter("password");
        String note=req.getParameter("note");
        User user=new User();
        user.setId(userId);
        user.setAdminName(username);
        user.setPassword(password);
        user.setNote(note);
        UserDao userDao=new UserDaoImpl();
        userDao.update(user);
        resp.sendRedirect("./findall");
    }
}
